#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 3e5 + 5;

int n, m;
int a[N << 1];
int rt[N << 1], num;
struct Node {
  int cnt;
  int ch[2];
} tr[N * 40];
#define cnt(p) tr[p].cnt
#define lc(p) tr[p].ch[0]
#define rc(p) tr[p].ch[1]
int newnode(int p) {
  static int tot = 0;
  ++tot;
  cnt(tot) = cnt(p);
  lc(tot) = lc(p);
  rc(tot) = rc(p);
  return tot;
}
void insert(int& rt, int x) {
  rt = newnode(rt);
  int p = rt;
  per(i, 23, 0) {
    int c = ((x >> i) & 1);
    if (c)
      rc(p) = newnode(rc(p)), p = rc(p);
    else
      lc(p) = newnode(lc(p)), p = lc(p);
    cnt(p)++;
  }
}

int query(int L, int R, int x) {
  int res = 0;
  int p1 = L > 1 ? rt[L - 2] : 0;
  int p2 = rt[R - 1];
  per(i, 23, 0) {
    int c = ((x >> i) & 1);
    if (cnt(tr[p2].ch[c]) <= cnt(tr[p1].ch[c])) c ^= 1;
    if (c) res |= 1 << i;
    p1 = tr[p1].ch[c], p2 = tr[p2].ch[c];
  }
  return res ^ (~x);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  insert(rt[0], 0);
  rep(i, 1, n) {
    int x;
    cin >> x;
    a[i] = a[i - 1] ^ x;
    rt[i] = rt[i - 1];
    insert(rt[i], a[i]);
  }
  num = n;
  while (m--) {
    char op;
    int x, y, z;
    cin >> op;
    if (op == 'A') {
      cin >> x;
      ++num;
      a[num] = a[num - 1] ^ x;
      rt[num] = rt[num - 1];
      insert(rt[num], a[num]);
    } else {
      cin >> x >> y >> z;
      cout << query(x, y, ~(a[num] ^ z)) << endl;
    }
  }
  return 0;
}